home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18368 < prev    next >
Encoding:
Text File  |  1996-08-05  |  986 b   |  43 lines

  1. Path: clients1.news.internex.net!usenet
  2. From: steve@icarus.icarus.com (Stephen Williams)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Can somebody explain me how to do this in C++
  5. Date: 19 Apr 1996 18:28:42 -0700
  6. Organization: Picture Elements, Inc.
  7. Sender: steve@icarus.icarus.com
  8. Message-ID: <x720lj1y5x.fsf@icarus.icarus.com>
  9. References: <4hkb2o$ko3@mo6.rc.tudelft.nl> <4keb0h$d5e@bilbo.nask.org.pl>
  10. NNTP-Posting-Host: icarus.icarus.com
  11. In-reply-to: piotrpar@blue.maloka.waw.pl's message of Tue, 09 Apr 1996
  12.     18:45:40 GMT
  13. X-Newsreader: Gnus v5.1
  14.  
  15.  
  16. Try this:
  17.  
  18. class Base {
  19.     [...stuff...]
  20.  
  21. };
  22.  
  23. class D1 : public Base {
  24.     [...stuff...]
  25. };
  26.  
  27. class D2 : public Base {
  28.     [...stuff...]
  29. };
  30.  
  31. Notice that the Base class is a PUBLIC base class, so
  32.  
  33.     D1 bar;
  34.     Base *foo = &bar;
  35.  
  36. works fine without any casting. It is best to avoid explicit
  37. casts. They are evil.
  38.  
  39. -- 
  40. Steve Williams                Fight License Managers!
  41. steve@icarus.com              Buy from vendors who use
  42. steve@picturel.com                Honor system licensing!
  43.